
import type {AdminUpdateParams, SearchParams, UpdateUserLoginParams, UserVO} from "@/api/User.ts";
import type { PageResult } from '@/api/Common.ts'
import httpClient from '@/api/client.ts'

export const UserApi ={
  getUser: async (params: string): Promise<UserVO | null> => {
      const {data} = await httpClient.get<UserVO>(`/user/login-info`,{params: {userId: params}})
      return data
  },
  updateLoginUser: async (params: UpdateUserLoginParams): Promise<boolean> => {
    const {data} = await httpClient.post(`/user/update-login`, params)
    return data
  },
  search: async (param:SearchParams) : Promise<PageResult<UserVO>> => {
    const {data} = await httpClient.post<PageResult<UserVO>>(`/user/search`, param)
    return data
  },

  updateUser: async (params: AdminUpdateParams): Promise<boolean> => {
    const {data} = await httpClient.post(`/admin/user/update`, params)
    return data
  },
  deleteUser: async (params: string): Promise<boolean> => {
    const {data} = await httpClient.post(`/admin/user/delete`, null, { params: { id: params } })
    return data
  },
}
